home *** CD-ROM | disk | FTP | other *** search
/ Aminet 37 / Aminet 37 (2000)(Schatztruhe)[!][Jun 2000].iso / Aminet / dev / cross / Avr.lha / Atmel / INCCT_Programmer / Src / progress.c < prev    next >
C/C++ Source or Header  |  1999-07-03  |  2KB  |  98 lines

  1. #include <exec/types.h>
  2. #include <intuition/intuition.h>
  3. #include <graphics/gfx.h>
  4.  
  5. #include <clib/exec_protos.h>
  6. #include <clib/graphics_protos.h>
  7. #include <clib/intuition_protos.h>
  8. #include <clib/gadtools_protos.h>
  9.  
  10. #include <stdio.h>
  11. #include "progress.h"
  12.  
  13. struct TextFont *PR_Font=NULL;
  14. struct Screen   *PR_Mysc=NULL;
  15. struct Window   *PR_Mywin=NULL;
  16. UWORD           PR_Topborder;
  17. BYTE ProgressHere=0;
  18. struct TextAttr ProgTopaz80 = { "topaz.font", 8, 0, 0, };
  19.  
  20. int OpenMyWindow(void);
  21. int CloseMyWindow(void);
  22.  
  23. int Progress(int Got, int OutOf)
  24. {
  25.   switch(ProgressHere)
  26.   {
  27.     case 0:   
  28.           if(OpenMyWindow())
  29.           {
  30.             ProgressHere=1;
  31.           }
  32.           else
  33.           {
  34.             ProgressHere=2;
  35.           }
  36.          break; 
  37.     case 1:
  38.           RectFill(PR_Mywin->RPort,PR_Mywin->BorderLeft,PR_Topborder,(int)((float)Got/OutOf*195),(PR_Topborder<<1)-1);
  39.  
  40.           break;
  41.  
  42.     default:
  43.            break;
  44.   }
  45.           
  46.   return 1;
  47. }
  48.  
  49. int OpenMyWindow(void)
  50. {
  51.   void            *vi;
  52.  
  53.   if ( (PR_Font = OpenFont(&ProgTopaz80)) )
  54.   {
  55.     if ( (PR_Mysc = LockPubScreen(NULL)) )
  56.     {
  57.       if ( (vi = GetVisualInfo(PR_Mysc, TAG_END)) )
  58.       {
  59.         PR_Topborder = PR_Mysc->WBorTop + (PR_Mysc->Font->ta_YSize + 1);
  60.         if ((PR_Mywin = OpenWindowTags(NULL,
  61.                         WA_Title,     "Progress",
  62.                         WA_AutoAdjust,    TRUE,
  63.                         WA_Width,       200,      WA_MinWidth,        50,
  64.                         WA_InnerHeight, PR_Topborder,  WA_MinHeight,       6,
  65.                         WA_DragBar,    TRUE,      WA_DepthGadget,   TRUE,
  66.                         WA_Activate,   TRUE,      WA_CloseGadget,   FALSE,
  67.                         WA_SizeGadget, FALSE,      WA_SimpleRefresh, FALSE,
  68.                         WA_IDCMP, 0,
  69.                         WA_PubScreen, PR_Mysc,
  70.                         TAG_END)))
  71.         {
  72.           return 1;   /*did it*/
  73.         }
  74.       }
  75.     }
  76.   }
  77.   return 0; /*failed*/
  78. }
  79.  
  80. int FinishProgress(void)
  81. {
  82.   CloseMyWindow();
  83.   ProgressHere=0;
  84.   return 1;
  85. }
  86.  
  87. int CloseMyWindow(void)
  88. {
  89.   if(PR_Mysc) UnlockPubScreen(NULL, PR_Mysc);
  90.   if(PR_Font) CloseFont(PR_Font);
  91.   if(PR_Mywin) CloseWindow(PR_Mywin);
  92.   PR_Mysc=NULL;
  93.   PR_Font=NULL;
  94.   PR_Mywin=NULL;
  95.   return 1;
  96. }
  97.  
  98.